package com.lune.job.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lune.job.mapper.ProjectMapper;
import com.lune.job.pojo.Project;
import com.lune.job.service.IProjectService;
import com.lune.job.service.IResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Caiyilin
 * @since 2022-03-06
 */
@Service
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements IProjectService {

    @Autowired
    private ProjectMapper projectMapper;

    @Autowired
    private IResumeService resumeService;

    @Override
    public IPage<Project> queryPage(Integer currentPage, Integer size, Project project) {
        Page<Project> page = new Page<>(currentPage, size);
        IPage<Project> intentionIPage = projectMapper.queryPage(page, project);
        return intentionIPage;
    }

    @Override
    public List<Project> queryByCon(Project project) {
        List<Project> projects = projectMapper.queryByCon(project);
        projects.forEach(item -> {
            item.setResume(resumeService.getById(item.getResume_id()));
        });
        return projects;
    }
}
